/**
 * Copyright (c) 2016, 2024, All rights reserved.
 * Powered by [liangyafeng@duplicall.com] On 2024-05-07 13:34:29
 */
package com.yafengliang.config;

import jakarta.websocket.*;
import jakarta.websocket.server.ServerEndpoint;
import org.springframework.stereotype.Component;


/**
 *
 * <p>Project: SpringBoot - AmplitudeEndpoint
 * <p>@Author: liangyafeng@duplicall.com On 2024-05-07 13:34:29
 *
 * <p>@Description: 
 */
@Component
@ServerEndpoint("/websocket/amplitude")
public class AmplitudeEndpoint {

    @OnOpen
    public void onOpen(Session session) {
        // Handle WebSocket connection opened
    }

    @OnClose
    public void onClose(Session session) {
        // Handle WebSocket connection closed
    }

    @OnError
    public void onError(Session session, Throwable error) {
        // Handle WebSocket error
    }

    @OnMessage
    public void onMessage(String message, Session session) {
        // Handle WebSocket message received
    }

    public static void sendAmplitude(String amplitude) {
        // Send amplitude data to all connected clients
        // You can iterate through all the sessions and send the data using session.getBasicRemote().sendText("amplitude:" + amplitude);
    }

}
